package com.it.web;

import com.it.entity.aiClaimRegistration.AiClaimRegistration;
import com.it.service.AiClaimRegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import utils.R;

/**
 * <p>
 * 理赔立案信息表（查勘后符合标准的立案记录） 前端控制器
 * </p>
 *
 * @author sunwz
 * @since 2025年09月20日
 */
@RestController
@RequestMapping("/aiClaimRegistration")
public class AiClaimRegistrationController {

    @Autowired
    private AiClaimRegistrationService claimRegistrationService;

    /**
     * 分页查询立案列表
     * @param pageNum 页码
     * @param pageSize 每页条数
     * @param registrationId 立案号
     * @param reportId 报案号
     * @param status 立案状态
     * @return 分页结果
     */
    @GetMapping("/list")
    public R list(@RequestParam(value = "pageNum",required = false,defaultValue = "1") int pageNum,
                  @RequestParam(value = "pageSize",required = false,defaultValue = "5") int pageSize,
                  @RequestParam(value = "registrationId",required = false) String registrationId,
                  @RequestParam(value = "reportId",required = false) String reportId,
                  @RequestParam(value = "status",required = false) Integer status
    ) {
        return claimRegistrationService.list(pageNum,pageSize,registrationId,reportId,status);
    }

    // 查看详情根据立案号
    @GetMapping("/get/{registrationId}")
    public R getById(@PathVariable("registrationId") String registrationId) {
        return claimRegistrationService.getByRegistrationId(registrationId);
    }

    // 删除立案根据立案号
    @DeleteMapping("/delete/{registrationId}")
    public R deleteById(@PathVariable("registrationId") String registrationId) {
        return claimRegistrationService.DeleteById(registrationId);
    }

    // 修改立案信息状态
    @PutMapping("/updateStatus")
    public R updateStatus(@RequestParam(value = "registrationId",required = false) String registrationId,
                          @RequestParam("registrationStatus") Integer status,
                          @RequestParam("cancelReason") String cancelReason){
        return claimRegistrationService.updateStatus(registrationId,status,cancelReason);
    }

    // 新增立案信息
    @PostMapping("")
    public R insert(@RequestBody AiClaimRegistration aiClaimRegistration) {
        return claimRegistrationService.insert(aiClaimRegistration);
    }

    // 查看详情根据报案号
    @GetMapping("/getByReportNo/{reportNo}")
    public R getByReportNo(@PathVariable("reportNo") String reportNo) {
        return claimRegistrationService.getByReportNo(reportNo);
    }

    //根据保单号查询
    @GetMapping("/selectByPolicyId")
    public R select(@RequestParam(value = "PolicyId") String PolicyId){
        return claimRegistrationService.select(PolicyId);
    }
}
